//
//  singleOperationQueue.m
//  CarWorld
//
//  Created by yuyu on 15/3/30.
//  Copyright (c) 2015年 CarWorldTeam. All rights reserved.
//

#import "singleOperationQueue.h"

@interface singleOperationQueue ()
@end
static singleOperationQueue *singleQueue=nil;
@implementation singleOperationQueue

+ (singleOperationQueue *)shareQueue
{
#if 0
    @synchronized(self)
    {
        if (singleQueue==nil) {
            singleQueue = [[singleOperationQueue alloc] init];
            singleQueue.queue = [[[NSOperationQueue alloc] init] autorelease];
            singleQueue.maxCount = 1;
        }
        return singleQueue;
    }
#else
    //通常用来创建单例对象
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        singleQueue = [[singleOperationQueue alloc] init];
        singleQueue.queue = [[[NSOperationQueue alloc] init] autorelease];
        [singleQueue.queue setMaxConcurrentOperationCount:1];
        singleQueue.maxCount = 1;
        
    });
    return singleQueue;
#endif

}

- (void)setMaxCount:(NSInteger)maxCount
{
    _maxCount = maxCount;
    [_queue setMaxConcurrentOperationCount:maxCount];
}

@end
